All right, So I'm in my zombie game and we have our boulder traps set up just the parts, no scripts.
We've got to ramp our stop or our boulder and a trigger.
So we need to make this work.
Let's go over to our boulder trap and start doing some scripting on the boulder trap level.
I'm going to add a script here.
I'll hit the plus sign script.
And the reason I have it on this level is this script is going to interact with more than one part.
If it was only going to interact with one part, I'd put it on that part.
But we are going to have to interact with both the stopper and the trigger and actually we're going
to do the boulder in the next video because we want to put sound on it.
So I'm going to call this script trigger it.
Right.
Hopefully that's not too close to a name.
Is Trigger, right?
Trigger It is the script.
And you got a little icon that makes it look like a script, too.
So let's get a variable for our boulder trap.
Let's say a boulder trap, and that's script dot parent.
And then in the boulder trap, we have a trigger.
We're going to need a variable for that trigger boulder trap trigger, right?
So Boulder trap is on the model level, and the trigger is one child underneath, right?
The first child of the boulder trap.
Cool.
And then we'll get the stopper.
Stopper is the same thing, right?
We have Boulder trap dot and you can even see it there.
Stopper.
Cool.
If you don't see it, then you're going to have to look around.
Something happen.
Something went wrong.
All right, Now we need a function to handle our touch event for the trigger.
So when I say local function, we're only going to have one touch event in this in this script.
So I'm going to call this on touch.
What's that other part?
Right.
Whenever we do a touch event, we're going to get another part.
That's the part that touched our part.
And the part that we're touching is the trigger.
So we have the trigger touched, connect on touch.
So this will be like a foot or something like that?
Probably a foot.
We're going to step on it.
So if it is a foot.
The parent will be the character, and then we'll be able to find a humanoid proving that it is a character
or a non playing character.
If a ball rolls over it, we're not going to trigger the trap.
So I'm going to look for the humanoid local cube.
That's my variable.
Some other part, maybe a foot parent find first child that is a humanoid.
So if this is the character, there will be a humanoid, if it's the character and then let's do it
if statement just to make sure, make sure it wasn't something weird that happened like a ball or I
don't know, something else, a tree.
Let's go ahead.
And now that we know that it's the humanoid, we are going to remove the stopper.
How do we remove the stopper?
I'm always going to put hinges on it, but I'm just going to make it easy because this is our first
kind of our first game asset, right?
We did some simple ones with the coin and the health but let's do stopper will make can collide equal
to false so it's essentially not holding back the ball, the the ball or the boulder and then we'll
get the stopper transparency and make it invisible.
One essentially, boom, it's gone.
Let's go ahead and try it out, see what we got.
You should put a print statement in there, too.
That's a good way to check to see what's happening.
We can go here to view output window.
We don't have any print statements in there.
I know this will work.
It's pretty simple.
But if it doesn't.
So there's no damaged script, so it doesn't hurt you.
But we're going to do that, too, if you.
If it doesn't work for you.
If the boulder doesn't go, what you should do is put print statements above the if statement and below
the statement down in here to see what's being printed out.
Typically this is spelt wrong or you forgot that or you'll see something red down here, red and scary,
and then you'll know that something went wrong.
So that's how you do some troubleshooting.
All right.
So the next video we're going to add to this, we're going to have to make the ball go back.
We're going to have to put damage on there.
We're going to put a sound on there.